
SET NAMES utf8mb4;
SET FOREIGN_KEY_CHECKS = 0;

-- ----------------------------
-- Table structure for t_branch
-- ----------------------------
DROP TABLE IF EXISTS `t_branch`;
CREATE TABLE `t_branch` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `sn` varchar(50) DEFAULT NULL COMMENT '内部编码',
  `pid` int(11) DEFAULT NULL COMMENT '父级id',
  `code` varchar(40) NOT NULL COMMENT '机构代码',
  `name` varchar(40) NOT NULL COMMENT '名称',
  `full_name` varchar(40) NOT NULL COMMENT '全称',
  `type` varchar(10) NOT NULL COMMENT '类型',
  `leader` varchar(40) DEFAULT NULL COMMENT '负责人',
  `phone` varchar(40) DEFAULT NULL COMMENT '联系电话',
  `email` varchar(100) DEFAULT NULL COMMENT '电子邮箱',
  `fax` varchar(20) DEFAULT NULL COMMENT '传真',
  `address` varchar(100) DEFAULT NULL COMMENT '联系地址',
  `remark` varchar(255) DEFAULT NULL COMMENT '备注信息',
  `zipcode` varchar(40) DEFAULT NULL COMMENT '邮政编码',
  `sort_rank` int(11) DEFAULT NULL COMMENT '顺序',
  `enable` char(1) DEFAULT '1' COMMENT '启用/禁用',
  `update_time` datetime DEFAULT NULL COMMENT '最后更新时间',
  `create_time` datetime DEFAULT NULL COMMENT '创建时间',
  `create_user` varchar(20) DEFAULT NULL COMMENT '创建用户',
  `update_user` varchar(20) DEFAULT NULL COMMENT '更改用户',
  `level` varchar(2) DEFAULT NULL COMMENT '树层级',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `index_ancestors` (`sn`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=17 DEFAULT CHARSET=utf8mb4 COMMENT='组织机构';

-- ----------------------------
-- Records of t_branch
-- ----------------------------
BEGIN;
INSERT INTO `t_branch` (`id`, `sn`, `pid`, `code`, `name`, `full_name`, `type`, `leader`, `phone`, `email`, `fax`, `address`, `remark`, `zipcode`, `sort_rank`, `enable`, `update_time`, `create_time`, `create_user`, `update_user`, `level`) VALUES (1, '1|', NULL, '01', 'EasyAdmin', 'EasyAdmin', '1', '', NULL, NULL, NULL, NULL, NULL, NULL, NULL, '1', NULL, NULL, NULL, NULL, '1');
INSERT INTO `t_branch` (`id`, `sn`, `pid`, `code`, `name`, `full_name`, `type`, `leader`, `phone`, `email`, `fax`, `address`, `remark`, `zipcode`, `sort_rank`, `enable`, `update_time`, `create_time`, `create_user`, `update_user`, `level`) VALUES (16, '1|g|', 1, 'c', '测试1', '测试机构', '2', NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for t_branch_role
-- ----------------------------
DROP TABLE IF EXISTS `t_branch_role`;
CREATE TABLE `t_branch_role` (
  `branch_sn` varchar(20) NOT NULL COMMENT '编码',
  `role` varchar(20) NOT NULL,
  PRIMARY KEY (`branch_sn`,`role`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of t_branch_role
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_config
-- ----------------------------
DROP TABLE IF EXISTS `t_config`;
CREATE TABLE `t_config` (
  `sn` varchar(50) NOT NULL COMMENT '编码',
  `value` varchar(300) DEFAULT NULL COMMENT '值',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`sn`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='配置项';

-- ----------------------------
-- Records of t_config
-- ----------------------------
BEGIN;
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.CopyRight', '2022 乌鲁木齐掌新动力电子信息技术限公司 版权所有', '2022-07-06 17:23:40');
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.LoginBgImg', 'https://s.cn.bing.net/th?id=OHR.BasaltGiants_ZH-CN4038085235_1920x1080.jpg&rf=LaDigue_1920x1080.jpg', '2022-07-13 21:43:33');
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.LogoUrl', 'img/logo.png', '2022-03-21 16:03:57');
INSERT INTO `t_config` (`sn`, `value`, `update_time`) VALUES ('PlatformConfig.SystemName', 'EasyAdmin', '2022-06-16 17:47:54');
COMMIT;

-- ----------------------------
-- Table structure for t_dictionary
-- ----------------------------
DROP TABLE IF EXISTS `t_dictionary`;
CREATE TABLE `t_dictionary` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT '字典ID',
  `name` varchar(255) DEFAULT NULL COMMENT '名称',
  `rank` int(11) DEFAULT NULL COMMENT '排序',
  `sn` varchar(50) DEFAULT NULL COMMENT '编码',
  `type` varchar(50) DEFAULT NULL COMMENT '字典类型',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  `is_fixed` tinyint(1) DEFAULT NULL COMMENT '是否为系统固定编码',
  PRIMARY KEY (`id`) USING BTREE
) ENGINE=InnoDB AUTO_INCREMENT=89 DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of t_dictionary
-- ----------------------------
BEGIN;
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (1, '机构类型', 1, 'BranchType', 'dict', '2022-02-21 12:08:32', NULL);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (2, '类型1', 1, '1', 'BranchType', '2022-03-25 18:58:04', NULL);
INSERT INTO `t_dictionary` (`id`, `name`, `rank`, `sn`, `type`, `update_time`, `is_fixed`) VALUES (3, '类型2', 2, '2', 'BranchType', '2022-03-25 18:58:11', NULL);
COMMIT;

-- ----------------------------
-- Table structure for t_job_info
-- ----------------------------
DROP TABLE IF EXISTS `t_job_info`;
CREATE TABLE `t_job_info` (
  `id` varchar(50) NOT NULL,
  `cron` varchar(50) DEFAULT NULL COMMENT 'cron表达式',
  `memo` varchar(255) DEFAULT NULL COMMENT '说明',
  `last_time` datetime DEFAULT NULL COMMENT '最后一次执行时间',
  `enable` tinyint(4) DEFAULT '1' COMMENT '是否可用',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COMMENT='定时任务信息';

-- ----------------------------
-- Records of t_job_info
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_job_log
-- ----------------------------
DROP TABLE IF EXISTS `t_job_log`;
CREATE TABLE `t_job_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `task_id` varchar(50) NOT NULL COMMENT '任务ID',
  `execute_time` datetime DEFAULT NULL COMMENT '执行时间',
  `take_time` mediumtext COMMENT '执行时长（毫秒）',
  `status` varchar(5) DEFAULT NULL COMMENT '状态',
  `error_info` varchar(100) DEFAULT NULL COMMENT '错误信息',
  `ip` varchar(30) DEFAULT NULL COMMENT '执行任务的IP',
  `server_id` varchar(20) DEFAULT NULL COMMENT '服务ID',
  `user_name` varchar(50) DEFAULT NULL COMMENT '执行用户',
  PRIMARY KEY (`id`),
  KEY `idx_task_id` (`task_id`) COMMENT '任务ID'
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of t_job_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_operation_log
-- ----------------------------
DROP TABLE IF EXISTS `t_operation_log`;
CREATE TABLE `t_operation_log` (
  `id` bigint(20) NOT NULL AUTO_INCREMENT COMMENT '主键',
  `module` varchar(20) CHARACTER SET utf8 DEFAULT NULL COMMENT '所属模块',
  `operate` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '操作',
  `operate_type` varchar(10) CHARACTER SET utf8 DEFAULT NULL COMMENT '操作类型',
  `user_name` varchar(50) CHARACTER SET utf8 DEFAULT NULL COMMENT '用户',
  `user_type` varchar(10) CHARACTER SET utf8 DEFAULT NULL COMMENT '用户类型',
  `ip` varchar(30) CHARACTER SET utf8 DEFAULT NULL COMMENT '用户地址',
  `path` varchar(100) DEFAULT NULL COMMENT '请求地址',
  `query` varchar(100) CHARACTER SET utf8 DEFAULT NULL COMMENT '请求参数',
  `body` text CHARACTER SET utf8 COMMENT '请求内容',
  `status` varchar(10) DEFAULT NULL COMMENT '状态',
  `create_time` datetime DEFAULT NULL ON UPDATE CURRENT_TIMESTAMP COMMENT '时间',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=167 DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of t_operation_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_role
-- ----------------------------
DROP TABLE IF EXISTS `t_role`;
CREATE TABLE `t_role` (
  `sn` varchar(20) NOT NULL COMMENT '编码',
  `name` varchar(20) DEFAULT NULL COMMENT '角色名',
  `role_type` varchar(20) DEFAULT NULL COMMENT '角色类型',
  `scope` varchar(20) DEFAULT NULL COMMENT '权限范围',
  PRIMARY KEY (`sn`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of t_role
-- ----------------------------
BEGIN;
INSERT INTO `t_role` (`sn`, `name`, `role_type`, `scope`) VALUES ('admin', '系统管理员', NULL, '1');
INSERT INTO `t_role` (`sn`, `name`, `role_type`, `scope`) VALUES ('user', '用户', NULL, '4');
COMMIT;

-- ----------------------------
-- Table structure for t_role_permission
-- ----------------------------
DROP TABLE IF EXISTS `t_role_permission`;
CREATE TABLE `t_role_permission` (
  `role` varchar(20) NOT NULL,
  `permission` varchar(20) NOT NULL,
  PRIMARY KEY (`role`,`permission`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of t_role_permission
-- ----------------------------
BEGIN;
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.branch');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.config');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.dictionary');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.role');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user.add');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user.delete');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('admin', 'platform.user.edit');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'Home');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.branch');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.config');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.dictionary');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.role');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user.add');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user.delete');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'platform.user.edit');
INSERT INTO `t_role_permission` (`role`, `permission`) VALUES ('user', 'WORKS');
COMMIT;

-- ----------------------------
-- Table structure for t_slow_sql_log
-- ----------------------------
DROP TABLE IF EXISTS `t_slow_sql_log`;
CREATE TABLE `t_slow_sql_log` (
  `id` int(11) NOT NULL AUTO_INCREMENT,
  `log_sql` varchar(255) DEFAULT NULL COMMENT '调用SQL语句',
  `take_time` int(11) DEFAULT NULL COMMENT '执行时长（毫秒）',
  `log_time` timestamp NULL DEFAULT NULL COMMENT '执行记录时间',
  `code_trace` varchar(255) DEFAULT NULL COMMENT '代码位置跟踪',
  `over_time_count` int(11) DEFAULT NULL COMMENT '超时次数',
  PRIMARY KEY (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=2 DEFAULT CHARSET=utf8mb4 COMMENT='慢SQL记录日志';

-- ----------------------------
-- Records of t_slow_sql_log
-- ----------------------------
BEGIN;
COMMIT;

-- ----------------------------
-- Table structure for t_user
-- ----------------------------
DROP TABLE IF EXISTS `t_user`;
CREATE TABLE `t_user` (
  `id` int(11) NOT NULL AUTO_INCREMENT COMMENT 'ID',
  `username` varchar(40) NOT NULL COMMENT '用户名',
  `password` varchar(128) NOT NULL COMMENT '密码',
  `user_type` char(1) DEFAULT NULL COMMENT '用户类型',
  `name` varchar(20) DEFAULT NULL COMMENT '姓名',
  `branch_sn` varchar(20) DEFAULT NULL COMMENT '部门编码',
  `avatar` varchar(255) DEFAULT NULL COMMENT '头像',
  `phone` varchar(40) DEFAULT NULL COMMENT '手机号',
  `enable` tinyint(1) DEFAULT '0' COMMENT '启用',
  `gender` varchar(1) DEFAULT '0' COMMENT '性别',
  `create_user` varchar(40) DEFAULT NULL COMMENT '创建人',
  `login_ip` varchar(255) DEFAULT NULL COMMENT '最后登录IP',
  `login_time` datetime DEFAULT NULL COMMENT '最后登录时间',
  `create_time` datetime DEFAULT NULL COMMENT '记录创建时间',
  `update_time` datetime DEFAULT NULL COMMENT '更新时间',
  PRIMARY KEY (`id`) USING BTREE,
  UNIQUE KEY `idx_username` (`username`) USING BTREE,
  KEY `idx_branch_sn` (`branch_sn`)
) ENGINE=InnoDB AUTO_INCREMENT=9 DEFAULT CHARSET=utf8mb4 COMMENT='用户登录账户表';

-- ----------------------------
-- Records of t_user
-- ----------------------------
BEGIN;
INSERT INTO `t_user` (`id`, `username`, `password`, `user_type`, `name`, `branch_sn`, `avatar`, `phone`, `enable`, `gender`, `create_user`, `login_ip`, `login_time`, `create_time`, `update_time`) VALUES (1, 'admin', '0ee0a1f62b6d583937a2897b5f720f49', 'U', '超级管理员', '1|', NULL, '13567897656', 1, 'M', NULL, NULL, NULL, NULL, NULL);
INSERT INTO `t_user` (`id`, `username`, `password`, `user_type`, `name`, `branch_sn`, `avatar`, `phone`, `enable`, `gender`, `create_user`, `login_ip`, `login_time`, `create_time`, `update_time`) VALUES (2, 'test', 'f8c1321bfd21bd047f6d15c3ec072d3a', NULL, '测试用户1', '1|g|', NULL, NULL, 1, 'M', NULL, NULL, NULL, NULL, NULL);
COMMIT;

-- ----------------------------
-- Table structure for t_user_role
-- ----------------------------
DROP TABLE IF EXISTS `t_user_role`;
CREATE TABLE `t_user_role` (
  `user_name` varchar(20) NOT NULL COMMENT '用户名',
  `role` varchar(20) NOT NULL,
  PRIMARY KEY (`user_name`,`role`) USING BTREE
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4;

-- ----------------------------
-- Records of t_user_role
-- ----------------------------
BEGIN;
INSERT INTO `t_user_role` (`user_name`, `role`) VALUES ('admin', 'admin');
INSERT INTO `t_user_role` (`user_name`, `role`) VALUES ('admin', 'user');
INSERT INTO `t_user_role` (`user_name`, `role`) VALUES ('test', 'user');
COMMIT;

SET FOREIGN_KEY_CHECKS = 1;
